/*******************************************************
* Copyright (c) 2018-2088, By XuXiang all rights reserved.
*
* FileName: NetMsgFight.cpp
* Summary: 战斗模块协议。
*
* Author: AutoBuild
* Date: --/--
*******************************************************/

#include "NetMsgFight.h"

namespace Competition
{
	namespace Net
	{
		//Empty class - CSFightStateRequest

		//----------------------------------------

		CSFightSelectRoleRequest::CSFightSelectRoleRequest() : RoleConfigID(0), Confirm(0)
		{
		}

		int CSFightSelectRoleRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			RoleConfigID = DataUtil::ReadInt32(buffer, i, &i);
			Confirm = DataUtil::ReadByte(buffer, i, &i);
			return i;
		}

		//----------------------------------------

		CSFightLoadingProgressRequest::CSFightLoadingProgressRequest() : Progress(0), Completed(0)
		{
		}

		int CSFightLoadingProgressRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			Progress = DataUtil::ReadInt16(buffer, i, &i);
			Completed = DataUtil::ReadByte(buffer, i, &i);
			return i;
		}

		//----------------------------------------

		//Empty class - CSFightOperateRequest

		//----------------------------------------

		CSFightResultRequest::CSFightResultRequest() : WinCamp(0)
		{
		}

		int CSFightResultRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			WinCamp = DataUtil::ReadByte(buffer, i, &i);
			return i;
		}

		//----------------------------------------

		//Empty class - CSFightQuitRequest

		//----------------------------------------

		CSFightFrameRecordRequest::CSFightFrameRecordRequest() : StartIndex(0), EndIndex(0)
		{
		}

		int CSFightFrameRecordRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			StartIndex = DataUtil::ReadInt32(buffer, i, &i);
			EndIndex = DataUtil::ReadInt32(buffer, i, &i);
			return i;
		}

		//----------------------------------------

		FightPlayerInfo::FightPlayerInfo() : UserID(0), RoleID(0), RoleConfigID(0), Confirm(0)
		{
		}

		int FightPlayerInfo::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteString(buffer, i, NickName);
			i = DataUtil::WriteSByte(buffer, i, RoleID);
			i = DataUtil::WriteInt32(buffer, i, RoleConfigID);
			i = DataUtil::WriteByte(buffer, i, Confirm);
			return i;
		}

		//----------------------------------------

		SCFightStateResponse::SCFightStateResponse() : State(0), PlayerCount(0), Param(0), RandSeed(0)
		{
		}

		int SCFightStateResponse::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteByte(buffer, i, State);
			i = DataUtil::WriteInt32(buffer, i, PlayerCount);
			for (int j = 0; j < PlayerCount; ++j)
			{
				i = PlayerList[j].Pack(buffer, i);
			}
			i = DataUtil::WriteInt32(buffer, i, Param);
			i = DataUtil::WriteUInt32(buffer, i, RandSeed);
			return i;
		}

		//----------------------------------------

		SCFightSelectRoleNotify::SCFightSelectRoleNotify() : UserID(0), RoleConfigID(0), Confirm(0)
		{
		}

		int SCFightSelectRoleNotify::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteInt32(buffer, i, RoleConfigID);
			i = DataUtil::WriteByte(buffer, i, Confirm);
			return i;
		}

		//----------------------------------------

		//Empty class - SCFightSelectRoleEndNotify

		//----------------------------------------

		SCFightLoadingProgressNotify::SCFightLoadingProgressNotify() : UserID(0), Progress(0), Completed(0)
		{
		}

		int SCFightLoadingProgressNotify::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteInt16(buffer, i, Progress);
			i = DataUtil::WriteByte(buffer, i, Completed);
			return i;
		}

		//----------------------------------------

		SCFightBeginNotify::SCFightBeginNotify() : RandSeed(0), StartTime(0), LastTime(0)
		{
		}

		int SCFightBeginNotify::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteUInt32(buffer, i, RandSeed);
			i = DataUtil::WriteInt64(buffer, i, StartTime);
			i = DataUtil::WriteInt32(buffer, i, LastTime);
			return i;
		}

		//----------------------------------------

		//Empty class - SCFightOperateFrameNotify

		//----------------------------------------

		SCFightResultNotify::SCFightResultNotify() : WinCamp(0)
		{
		}

		int SCFightResultNotify::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteByte(buffer, i, WinCamp);
			return i;
		}

		//----------------------------------------

		//Empty class - SCFightQuitResponse

		//----------------------------------------

		//Empty class - SCFightFrameRecordResponse
	}
}
